//
//  DYShopDecorateCollectionCell.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/20.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYShopDecorateCollectionCell.h"

@implementation DYShopDecorateCollectionCell

-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}
-(void)initView
{
    
    self.showImageView=({
        UIImageView *imageView=[Utils imageViewWithImage:IMG(@"img_upload")];
        imageView.contentMode=UIViewContentModeScaleAspectFill;
        imageView.userInteractionEnabled=YES;
        imageView.clipsToBounds=YES;
        imageView;
    });
    
    self.deleteButton=({
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:ClearColor action:@selector(deleteButtonClick) target:self title:nil image:@"icon_delete" font:12 textColor:WhiteColor];
        button;
    });
    
    [self addSubview:self.showImageView];
    [self addSubview:self.deleteButton];
    
    [self.showImageView makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(0);
    }];
    
    [self.deleteButton makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.equalTo(0);
        make.size.equalTo(CGSizeMake(BILIHEIGHT(18), BILIHEIGHT(18)));
    }];
    
    self.deleteButton.hidden=YES;
    
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(addPhoto)];
    [self.showImageView addGestureRecognizer:tap];
}
-(void)addPhoto
{
    !self.addBlock?:self.addBlock();
}
-(void)deleteButtonClick
{
    !self.deleteBlock?:self.deleteBlock();
}
@end
